<?php $view->extend('::layout.html.php') ?>

<?php $view['slots']->start('_content') ?>
<div class="contenu">
<?php echo $view->render(
            'LEAUserBundle:Default:etudMenu.html.php',
            array('user' => $user,
					 'refYear' => $refYear)
        ) ?>



<?php

    if ($alt==false) {
      die("Aucune information dispo à mettre à jour!");
    }

    $nbCols = 2;
    $space = 50;
    $width=500;
	$i = 0;

   do {
        $altCle = $alt['alternanceCle'];
        $et_pn = $alt['prenom_etud'] . " " . $alt['nom_etud'];
        $et_entrNom = $alt['nom_entreprise'];
        $et_entrCle = $alt['entrepriseCle'];
        $et_tel = $alt['tel_etud'];
        $et_m = $alt['mail_etud'];
        $et_mlille1 = $alt['mailLille1'];

        $t_p = $alt['prenom_prof'];
        $t_n = $alt['nom_prof'];
        $t_ref = $alt['profCle'];
        $entr_bureauRef = $alt['bureauRef'];

        $r_p = $alt['prenom_ref'];
        $r_n = $alt['nom_ref'];
        $r_fonction = $alt['fonct_ref'];
        $r_tel = $alt['tel_ref'];
        $r_m = $alt['mail_ref'];
        $r_cle= $alt['refCle'];
        $r2_cle= $alt['ref2Cle'];
        $r_opca = $alt['opca_ref'];

        $d_sign = $alt['signatureContrat'] == "0000-00-00" ? "" : $alt['signatureContrat'];
        $d_opca = $alt['accordOPCA'] == "0000-00-00" ? "" : $alt['accordOPCA'];
        $d_deb = $alt['debutContrat'] == "0000-00-00" ? "" : $alt['debutContrat'];
        $d_fin = $alt['finContrat'] == "0000-00-00" ? "" : $alt['finContrat'];

        $regie_entrCle=$alt['entrepriseRef'];
        $regie_bureauRef=$alt['regieBureauRef'];
        $regie_referent=$alt['regieReferentRef'];
        $regie_referent2=$alt['regieReferentRef2'];
        $regie_adresse=$alt['regisAdresse'];
        $entr_adresse=$alt['regisVille'];
        $ref_coords=$alt['refMail'];
        $ref2_coords=$alt['ref2Mail'];
        $regieRef_coords=$alt['regieRefMail'];
        $regieRef2_coords=$alt['regieRef2Mail'];
        $formationRef=$alt['formationRef'];
        $nbNotifs=$alt['notifAttribTuteur'];
        $estFA=substr($formationRef,strlen($formationRef)-2,2)=="FA";
?>
        <div id='cadre_0' class='contenu-item2 on'>
        <!--<form id='form0' name='form", $i, " method='post'> -->


         <table align='center' width='100%' style='font-size:11px'>
                <tr class='entete'>
                    <td colspan='2' style='border-width: 1px;border-style:solid;text-align:left' >
                        L'ETUDIANT : <?=$et_pn?> </td></tr>
                <tr><td>tél. perso</td><td><input type='text' value='<?=$et_tel?>' name='et_tel'/></td></tr>
                        <tr><td>e-mail</td><td><input type='text' value='<?=$et_m?>' name='et_m'/></td></tr>
                        <tr><td>e-mail Lille1</td><td> <?php echo (strlen($et_mlille1) > 0 ? $et_mlille1 : 'en attente d\'inscription');?></td></tr>

           <tr class='entete'>
           <td style='border-width: 1px;border-style:solid;text-align:left' colspan='2'>
                        LE TUTEUR :

<?php    /*    if (hasRole(RESP_ROLE))
            createTuteurSelect($conn, "t_ref", $t_ref, true, '');
        else {*/
             if ($nbNotifs>0) {
                echo $t_p, " ", $t_n;
             } else if ($t_ref) echo "en attente"; else echo "aucun";

             echo "<input type='hidden' value='", $t_ref, "' name='t_ref'/>";
       // }

?>
        </td></tr>
                <tr class='entete'><td style='text-align:left'>
                        L'ENTREPRISE : </td><td>
         <select name="entreprise" class="col-sm-6 col-xs-6">
           <?php while($entr = $entreprises->fetch()){
			  echo "<option value='",$entr['SANS ENTREPRISE'],"'>", $entr['SANS ENTREPRISE'], "</option>";
				}; ?>
           	</select>
        <a href='#' ><font size='-1'>nouvelle Entreprise</font></a>
        <br/>
              </td></tr>
              <tr><td>Bureau </td><td style='border-width: 1px;border-style:solid' >
       <select name="bureau" class="col-sm-6 col-xs-6">
           <?php while($bureau = $bureaux->fetch()){
			  echo "<option value='",$bureau['info'],"'>", $bureau['info'], "</option>";
				} ?>
           	</select>
          <br/><br/>
          <a  href=\"#\" ><font size='-1'>nouveau bureau</font></a>
            <br/><font size='-1' style='color:lightgrey'><div id='fa_bureau_cle_coords' style=".((strlen($entr_adresse)==0)?'display:none':'').">
            <a href=\"#\"> ... modifier adresse siège</a>
            </div>
            </font></td></tr>

       	<tr>
            <td>
                        Referent :
                        </td>
                        <td  style='border-width: 1px;border-style:solid'>

        <select name="referent" class="col-sm-6 col-xs-6">
           <?php while($referent = $referents->fetch()){
			  echo "<option value='",$referent['sans referent'],"'>", $referent['sans referent'], "</option>";
				} ?>
           	</select>
           	<br/><br/>
        <a  href=\"#\" ><font size='-1'>nouveau référent</font></a>
        <br/><font size='-1' style='color:lightgrey'><div id='fa_referent_cle_coords' style=".((strlen($ref_coords)==0)?'display:none':'').">
           <a href=\"#\" > ... modifier coordonnées</a>
            </div></font>
            </td></tr><tr>
            <td>
                        Referent 2 :
                        </td>
                        <td  style='border-width: 1px;border-style:solid'>
  <select name="referent2" class="col-sm-6 col-xs-6">
           <?php while($referent = $referents2->fetch()){
			  echo "<option value='",$referent['sans referent'],"'>", $referent['sans referent'], "</option>";
				} ?>
           	</select>
           	<br/><br/>
    	<a  href=\"#\" ><font size='-1'>nouveau référent</font></a>
        <br/>
            <font size='-1' style='color:lightgrey'>
            <div id='fa_referent2_cle_coords' style=".((strlen($ref2_coords)==0)?'display:none':'').">
           <a href=\"#\"> ... modifier coordonnées</a>
            </div></font>
                    </td>
                    </tr>


		<?php if ($estFA) { ?>
         <tr><td>OPCA concerné</td><td  style='border-width: 1px;border-style:solid'>
          <select name="opca" class="col-sm-6 col-xs-6">
           <?php while($opca = $opcas->fetch()){
			  echo "<option value='",$opca['INCONNUE'],"'>", $opca['INCONNUE'], "</option>";
				} ?>
           	</select>
          <!-- echo "<a href='".ABS_START_URL."/index.php?page=interface/inscrireOPCA_act'/><font size='-1'>nouvelle OPCA</font></a>"; -->
          </td></tr>
        <?php } ?>

   <tr class='entete'>
			<td style='text-align:left'> Contrat
				</td><td style='text-align:left'></td></tr>
				<tr><td>date de signature du contrat </td><td>
</td></tr>
           <?php /*
            $myCalendarSIGN = new calendar("d_sign", true);
	   $myCalendarSIGN->setIcon(ABS_START_URL."/calendar/images/iconCalendar.gif");
		$myCalendarSIGN->setDateYMD($d_sign);
		$myCalendarSIGN->disabledDay("sun");
		$myCalendarSIGN->setPath(ABS_START_URL."/calendar/");
		$myCalendarSIGN->setDateFormat('Y-F-j');
		$myCalendarSIGN->setAlignment('left', 'bottom');
              $myCalendarSIGN->writeScript();
*/
        echo "</td></tr>";
      if ($estFA) {
          echo "<tr><td>date de l'accord OPCA </td><td>";
/*
                    $myCalendarOPCA = new tc_calendar("d_opca", true);
                    $myCalendarOPCA->setIcon(ABS_START_URL."/calendar/images/iconCalendar.gif");
                    $myCalendarOPCA->setDate(intval(substr($d_opca,8,2)),intval(substr($d_opca,5,2)),intval(substr($d_opca,0,4)));
                    $myCalendarOPCA->disabledDay("sun");
                    //$myCalendarOPCA->dateAllow('' . date('d') . '-' . date('m') . '-' . date('Y'), '', false);
                    $myCalendarOPCA->setPath(ABS_START_URL."/calendar/");
                    $myCalendarOPCA->setDateFormat('Y-F-j');
                    $myCalendarOPCA->setAlignment('left', 'bottom');
                    //error_log("d_opca : ".substr($d_opca,8,2)." - ".substr($d_opca,5,2)." - ".substr($d_opca,0,4));
                    $myCalendarOPCA->writeScript();
*/
        echo "</td></tr>";
      }
      echo "<tr><td>début du contrat</td><td>";
/*
                    $myCalendarDebut = new tc_calendar("d_deb", true);
                    $myCalendarDebut->setIcon(ABS_START_URL."/calendar/images/iconCalendar.gif");
                    $myCalendarDebut->setDate(intval(substr($d_deb,8,2)),intval(substr($d_deb,5,2)),intval(substr($d_deb,0,4)));
                    $myCalendarDebut->disabledDay("sun");
                    //$myCalendarDebut->dateAllow('' . date('d') . '-' . date('m') . '-' . date('Y'), '', false);
                    $myCalendarDebut->setPath(ABS_START_URL."/calendar/");
                    $myCalendarDebut->setDateFormat('Y-F-j');
                    $myCalendarDebut->setAlignment('left', 'bottom');
                    error_log("d_deb : ".substr($d_deb,8,2)." - ".substr($d_deb,5,2)." - ".substr($d_deb,0,4));
                    $myCalendarDebut->writeScript();
*/

      echo "</td></tr><tr><td>fin du contrat</td><td>";
/*
                    $myCalendarFin = new tc_calendar("d_fin", true);
                    $myCalendarFin->setIcon(ABS_START_URL."/calendar/images/iconCalendar.gif");
                    $myCalendarFin->setDate(intval(substr($d_fin,8,2)),intval(substr($d_fin,5,2)),intval(substr($d_fin,0,4)));
                    $myCalendarFin->disabledDay("sun");
                    //$myCalendarFin->dateAllow('' . date('Y') . '-' . date('m') . '-' . date('d'), '', false);
                    $myCalendarFin->setPath(ABS_START_URL."/calendar/");
                    $myCalendarFin->setDateFormat('Y-F-j');
                    $myCalendarFin->setAlignment('left', 'bottom');
                    error_log("d_fin : ".substr($d_fin,8,2)." - ".substr($d_fin,5,2)." - ".substr($d_fin,0,4));

                    $myCalendarFin->writeScript();
*/
?>
     </td></tr>
     <tr class='entete'><td style='text-align:left'>
        REGIE :</td><td>
    <select name="regie" class="col-sm-6 col-xs-6">
           <?php while($regie = $regies->fetch()){
			  echo "<option value='",$regie['SANS ENTREPRISE'],"'>", $regie['SANS ENTREPRISE'], "</option>";
				} ?>
           	</select>
    <a href='#' ><font size='-1'>nouvelle Entreprise</font></a>

    <br/>
      </td></tr>
                     <tr><td>Bureau (lieu d'alternance)</td>
                       <td style='border-width: 1px;border-style:solid'>
        <select name="bureauAlt" class="col-sm-6 col-xs-6">
           <?php while($bureauAlt = $bureauxAlt->fetch()){
			  echo "<option value='",$bureauAlt['info'],"'>", $bureauAlt['info'], "</option>";
				} ?>
           	</select>
           	<br/><br/>
           	<a  href=\"#\" ><font size='-1'>nouveau bureau</font></a>
            <br/><font size='-1' style='color:lightgrey'><div id='fa_regie_bureau_cle_coords' style=".((strlen($regie_adresse)==0)?'display:none':'').">
            <a href=\"#\" > ... modifier adresse siège</a>
            </div>
            </font></td></tr>

      <tr>
            <td>
                        Referent :
                        </td>
                      <td style='border-width: 1px;border-style:solid'>
       <select name="referentRegie" class="col-sm-6 col-xs-6">
           <?php while($referentAlt = $referentsAlt->fetch()){
			  echo "<option value='",$referentAlt['sans referent'],"'>", $referentAlt['sans referent'], "</option>";
				} ?>
           	</select>
           	<br/><br/>
        <a  href=\"#\" ><font size='-1'>nouveau référent</font></a>
        <br/><font size='-1' style='color:lightgrey'><div id='fa_regie_referent_cle_coords' style=".((strlen($regieRef_coords)==0)?'display:none':'').">
           <a href=\"#\" > ... modifier coordonnées</a>
            </div></font>
</td></tr><tr>
            <td>
                        Referent 2 :
                        </td>
                        <td style='border-width: 1px;border-style:solid'>
                        <select name="referentRegie2" class="col-sm-6 col-xs-6">
           <?php while($referent2Alt = $referents2Alt->fetch()){
			  echo "<option value='",$referent2Alt['sans referent'],"'>", $referent2Alt['sans referent'], "</option>";
				} ?>
           	</select>
<br/><br/>
        <a  href=\"#\" ><font size='-1'>nouveau référent</font></a>
        <br/><font size='-1' style='color:lightgrey'><div id='fa_regie_referent2_cle_coords' style=".((strlen($regieRef2_coords)==0)?'display:none':'').">
           <a href=\"#\" > ... modifier coordonnées</a>
            </div></font></td></tr>

        <tr><td>
          <!--input type='button' value='Revenir en arrière' onclick='javascript:history.go(-1);'/-->
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       </td><td align='right'><input type='submit' style='background-color:orange' value='Valider'/></td>
                </tr>

        </table>
        </form>
        </div>

<?php
            $i++ ;
            echo     "</table>";
             echo "</div>";
 echo "</div>";
    }while ($alt = $alts->fetch());

?>

</div>